<?php
/**
 * @ClassName: Sdk
 * @Description: TODO
 * @author: gydtrade
 * @Date: 2025-10-14 11:26
 * @Version: V1.0.0
 */

namespace app\common\huifu;

use BsPaySdk\core\BsPay;

class Sdk
{
    protected static $inited = false;

    /**
     * 初始化SDK
     * @param mixed $configKey 使用的支付配置
     * @param bool $debug 是否调试
     * @param string $logDir 日志目录
     * @return void
     */
    public static function init($configKey = 'huifu', $debug = true, $logDir = 'huifu/sdk')
    {
        if (static::$inited) {
            return;
        }
        static::$inited = true;
        //引入sdk加载文件
        require_once app()->getRootPath() . 'vendor/huifurepo/dg-php-sdk/BsPaySdk/init.php';
        $config = config($configKey . '.'); //读取指定配置
        BsPay::init($config, true);
        BsPay::$isDebug = $debug;
        BsPay::$logDir  = app()->getRuntimePath() . 'log' . DIRECTORY_SEPARATOR . $logDir . DIRECTORY_SEPARATOR . date('Ym');
    }

}